<template>
  <div>
    <el-table :data='tableData' border stripe :height='offsetHeight' v-loading='loading' ref='tableData'>
      <el-table-column type='index' label='序号' width='80' align='center'>
      </el-table-column>
      <el-table-column prop='name' label='审核机构名称' align='center'>
      </el-table-column>
      <el-table-column label='创建时间' width='120' align='center'>
        <template slot-scope='{row}'>
          {{$util.formatDate(row.create_time)}}
        </template>
      </el-table-column>
      <el-table-column label='操作' width='200' align='center'>
        <template slot-scope='{row}'>
          <el-button type="primary" size="mini" @click="details(row.id)">详情</el-button>
          <el-button type="primary" size="mini" @click="exportReport(row.id)">导出报告</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 项目表单信息 -->
    <el-dialog title="项目上报" :visible.sync="historyShow" width="80%" @close="cancel" :destroy-on-close="true" top="0"
      append-to-body>
      <project-list-item :form-list="historyParams" @cancel="cancel"></project-list-item>
    </el-dialog>

    <block-report-item v-show="false" ref="blockReport"></block-report-item>
  </div>
</template>

<script>
import ProjectListItem from '@/components/Bid/ProjectList.vue'
import BlockReportItem from '@/components/Report/BlockReport'

export default {
  name: '',
  components: {
    ProjectListItem, BlockReportItem,
  },
  props: {
    projectId: {
      type: String,
      default: () => {
        return ''
      }
    }
  },
  data () {
    return {
      offsetHeight: document.documentElement.clientHeight - 350,
      loading: false,
      tableData: [],
      historyShow: false,
      historyParams: {},
    }
  },
  created () {
  },
  mounted () {
    this.init()
  },
  methods: {
    async init () {
      this.loading = true
      const res = await this.$http('blockHistoryList', {
        project_id: this.projectId
      })
      this.tableData = res
      this.loading = false
    },
    details (id) {
      this.historyParams = {
        id: id,
        type: 'choose'
      }
      this.historyShow = true
    },
    async exportReport (id) {
      this.saveLoading = true
      const res = await this.$http('blockChoose', {
        id: this.projectId,
        report_company_id: id
      })
      await this.$refs.blockReport.writerUpdate(this.projectId)
      this.saveLoading = false
    },
    async saveChoose () {
      const res = await this.$http('blockChoose', {
        id: this.formList.id,
        report_company_id: this.thirdId
      })
      await this.$refs.blockReport.writerUpdate(this.formList.id)
    },
    cancel () {
      this.historyParams = {}
      this.historyShow = false
    }
  },
  computed: {
  },
  watch: {
    projectId (val) {
      if (val) {
        this.init()
      }
    }
  }
}
</script>
<style lang='scss' scoped>
</style>